Micron Document
🌎 rns.kin.earth git 🌍

Node / dev / reticulum / files / RNS / Cryptography / PKCS7.py

Displaying Raw • Download

RNS/Cryptography/PKCS7.py 9d924dcd6d7d07bbcbf3d2d083a007d2f49a2afb (9d924dcd) Text, 1.54 KB

T8b949e# MIT License
T8b949e#
T8b949e# Copyright (c) 2022 Mark Qvist / unsigned.io
T8b949e#
T8b949e# Permission is hereby granted, free of charge, to any person obtaining a copy
T8b949e# of this software and associated documentation files (the "Software"), to deal
T8b949e# in the Software without restriction, including without limitation the rights
T8b949e# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
T8b949e# copies of the Software, and to permit persons to whom the Software is
T8b949e# furnished to do so, subject to the following conditions:
T8b949e#
T8b949e# The above copyright notice and this permission notice shall be included in all
T8b949e# copies or substantial portions of the Software.
T8b949e#
T8b949e# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
T8b949e# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
T8b949e# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
T8b949e# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
T8b949e# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
T8b949e# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
T8b949e# SOFTWARE.

Tff7b72class T56d364PKCS7Tb4b4b4:
Te6edf3BLOCKSIZE Tff7b72= T79c0ff16

Tf0883e@staticmethod
Tff7b72def Td2a8ffpadTb4b4b4(Te6edf3dataTb4b4b4, Te6edf3bsTff7b72=Te6edf3BLOCKSIZETb4b4b4)Tb4b4b4:
Te6edf3l Tff7b72= Tffa657lenTb4b4b4(Te6edf3dataTb4b4b4)
Te6edf3n Tff7b72= Te6edf3bsTff7b72-Te6edf3lTff7b72%Te6edf3bs
Te6edf3v Tff7b72= Tffa657bytesTb4b4b4(Tb4b4b4[Te6edf3nTb4b4b4]Tb4b4b4)
Tff7b72return Te6edf3dataTff7b72+Te6edf3vTff7b72*Te6edf3n

Tf0883e@staticmethod
Tff7b72def Td2a8ffunpadTb4b4b4(Te6edf3dataTb4b4b4, Te6edf3bsTff7b72=Te6edf3BLOCKSIZETb4b4b4)Tb4b4b4:
Te6edf3l Tff7b72= Tffa657lenTb4b4b4(Te6edf3dataTb4b4b4)
Te6edf3n Tff7b72= Te6edf3dataTb4b4b4[Tff7b72-T79c0ff1Tb4b4b4]
Tff7b72if Te6edf3n Tff7b72> Te6edf3bsTb4b4b4:
Tff7b72raise Tf85149ValueErrorTb4b4b4(Ta5d6ff"Ta5d6ffCannot unpad, invalid padding length of Ta5d6ff"Tff7b72+Tffa657strTb4b4b4(Te6edf3nTb4b4b4)Tff7b72+Ta5d6ff"Ta5d6ff bytesTa5d6ff"Tb4b4b4)
Tff7b72elseTb4b4b4:
Tff7b72return Te6edf3dataTb4b4b4[Tb4b4b4:Te6edf3lTff7b72-Te6edf3nTb4b4b4]

Served by rngit 1.5.2 - Generated in 0.06s